package shiyan2;
public class ComplexNumber
{
 double r,i;
  

public  ComplexNumber(){
	this.r=0;
	this.i=0;
}
public ComplexNumber(double r, double i){
	this.r=r;
	this.i=i;
}
public double GetRealPart(){
	return this.r;
}
public double GetImaginaryPart(){
	return this.i;
}
public void SetRealPart(double r){
	this.r=r;
}
public void SetImaginaryPart(double i){
	this.i=i;
}
public ComplexNumber ComplexAdd(ComplexNumber a,ComplexNumber b)    
{
	ComplexNumber temp = new ComplexNumber();
    temp.r = a.r + b.r;
    temp.i  = a.i  + b.i;
    return temp;
}
public ComplexNumber ComplexMinus(ComplexNumber a,ComplexNumber b)    
{
	ComplexNumber temp =new ComplexNumber();
    temp.r=a.r - b.r;
    temp.i =a.i - b.i;
    return temp;
}    
public ComplexNumber ComplexMulti(ComplexNumber a,ComplexNumber b)    
{
	ComplexNumber temp = new ComplexNumber();
    temp.r = a.r*b.r-a.i*b.i;
    temp.i  = a.r*b.i+a.i*b.r;
    return temp;
}
public void ComplexAdd(ComplexNumber c){
	this.r=this.r+c.r;
	this.i=this.i+c.i;
}


public void ComplexMinus(ComplexNumber c){
	this.r=this.r-c.r;
	this.i=this.i-c.i;
}
public void ComplexMulti(ComplexNumber c)                
{
    double temp=this.r;    
    this.r=this.r*c.r-this.i*c.i;
    this.i =temp*c.i+this.i*c.r;
}
public void printComplexNumber(){
	System.out.print(""+this.r+"+"+this.i+"i");
}

}